package cover.vertex;

import java.util.UUID;

/**
 * Special vertex for covering
 * 
 */
public class Vertex{
	
	public Vertex getCopy() throws CloneNotSupportedException {
		Vertex clone = new Vertex(this.isInCover, this.name);
		clone.ID = this.ID;
		return clone;
	}

	private final String name;
	//belongs to cover or not?
	private boolean isInCover = false;
	private UUID ID;

	{
		ID = UUID.randomUUID();
	}

	public Vertex(boolean cover, String name) {
		super();
		this.isInCover = cover;
		this.name = name;
	}

	public Vertex(String name) {
		super();
		this.name = name;
	}

	public boolean getCover() {
		return isInCover;
	}

	/**
	 * @return the iD
	 */
	public UUID getID() {
		return ID;
	}

	public void addToCover() {
		this.isInCover = true;
	}

	public String getName() {
		return name;
	}
	
	public String toString() {
		return "<" + this.name + ":" + isInCover + ">";
	}
	
	public int hashCode() {
		return (ID == null) ? 0 : ID.hashCode();
	}
	
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Vertex))
			return false;
		Vertex other = (Vertex) obj;
		if (ID == null) {
			if (other.ID != null)
				return false;
		} else if (!ID.equals(other.ID))
			return false;
		return true;
	}

}
